package com.heima.user.controller;

import com.heima.apis.user.ApUserRealnameControllerApi;
import com.heima.common.constans.UserConstants;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.dtos.AuthDto;
import com.heima.user.service.ApUserRealnameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Macrydy
 * @date 2020/11/9
 */
@RestController
@RequestMapping("/api/v1/auth")
public class ApUserRealnameController implements ApUserRealnameControllerApi {

    @Autowired
    private ApUserRealnameService apUserRealnameService;



    /**
     * 按照状态分页查询用户列表
     * @param dto
     * @return
     */
    @Override
    @GetMapping("/list")
    public ResponseResult loadListByStatus(@RequestBody AuthDto dto) {
        return apUserRealnameService.loadListByStatus(dto);
    }

    /**
     * 审核通过
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/authPass")
    public ResponseResult authPass(@RequestBody AuthDto dto) {
        return apUserRealnameService.updateStatusById(dto, UserConstants.PASS_AUTH);
    }


    /**
     * 审核失败
     * @param dto
     * @return
     */
    @Override
    @PostMapping("/authFail")
    public ResponseResult authFail(@RequestBody AuthDto dto) {
        return apUserRealnameService.updateStatusById(dto,UserConstants.FAIL_AUTH);
    }
}
